STEP 8: Let’s start to add the ability to make a basketball once the user clicks on your sprite.

An event is a block of code that runs when something happens—like when someone clicks on a sprite.

  • Click on in the toolkit.
  • Drag out Sprite Click and drop it at the bottom of your program.
  • Run your program and click on the sprite. You should see it say "Hello, name".

To navigate the page using the TAB key, first press ESC to exit the code editor.

stage.set_background("halfcourt") sprite = codesters.Sprite("player1") sprite.go_to(-175, -150) net = codesters.Sprite("basketballnet") net.go_to(215, 175) stage.set_gravity(10) sprite.set_gravity_off()
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)